//JS容错代码，不提示错误。
window.onerror=function (){return true;}
//<var id="user_levelIcon_${his.user_id}" class="levelIcon"></var>
$(document).ready(function (){
	initLevelIcon();
});
function initLevelIcon(){
	var uids = "";
	var uidArray = new Array();
	$(".levelIcon").each(function (i,n){
		var objId = $(n).attr("id");
		var uid = objId.replace("user_levelIcon_","");
		uids +=","+uid;
		uidArray[i] = uid;
	});
	if(uids.length>1){uids = uids.substring(1);}
	var isListStarPage =0;
	if($("#isListStarPage").val()!=undefined){
		isListStarPage = $("#isListStarPage").val();
	}
	var href = window.location.href;
	var currentPage = 1;
	if(href.indexOf("currentPage")>0){
		currentPage = href.substring(href.indexOf("currentPage=")+"currentPage=".length);
	}
	if(uids == ""){return;}
	//alert(uids);
	$.ajax({
			type: "POST",		
			url: "/room!getLevelIcon.jspa?currentPage="+currentPage+"&roomid="+$("#room_id").val()+"&isListStarPage="+isListStarPage+"&starUid="+uids, 
			dataType : "json",
       		complete : function (data, textStatus){
       			if(data.responseText==""){return;}
       			var jsonDataObject = eval("(" + data.responseText + ")");
       			var dataResult = jsonDataObject.result;
       			//alert(data);
       			if(dataResult==0){
       				var content = jsonDataObject.content;       				
       				var conArray = content.split("__");
       				var levelObjJson = jsonDataObject.levelObjJson;  
       				for(var i=0;i<uidArray.length;i++){
       					var idLevArray = conArray[i].split("_");
       					//var ttuid = idLevArray[0];
       					var ttuid = uidArray[i];//从页面中去到的ID集合
       					
       					var levArray = new Array();
       					if(idLevArray.length>1){
       						levArray = idLevArray[1].split(",");
       					}
       					var html = "";
       					for(var o=0;o<levArray.length;o++){
       						if(levArray[o]==""){continue;}
       						html += "<img src=\"/images/"+levArray[o]+".gif\"></img>";
       					}
       					if(levelObjJson!=undefined){
	       					var level = levelObjJson[ttuid]["level"];
	       					var objId = levelObjJson[ttuid]["starJobId"];
	       					if(level!=0&&objId!=0){
	       						html+="<img src='http://star.17guagua.com/resources/images/level/"+objId+"/"+level+".png' alt=\""+level+"\"></img>";
	       					}
       					}
       					$("#user_levelIcon_"+ttuid).replaceWith(html);        					
       				}
       			}
			}
		});
}